package ru.dc.object.commands;

/**
 * <h3>Syntax</h3>
 * <pre>$RevConnectToMe &lt;ClientNick> &lt;TargetNick>|</pre>
 *
 * <h3>Description</h3>
 * <p>A client sends this command to indicate that it wants &lt;TargetNick> to initiate a $ConnectToMe to it.
 * This is used when the client cannot accept inbound connections (i.e. is passive).</p>
 * <a href="http://www.teamfair.info/wiki/index.php?title=$RevConnectToMe">http://www.teamfair.info/wiki/index.php?title=$RevConnectToMe</a>
 */
public class RevConnectToMe extends Command {

    private String clientNick;
    private String targetNick;

    @Override
    public String generateCommand() {
        return getActualCommandName()+" "+getClientNick()+" "+getTargetNick();
    }

    @Override
    public String getActualCommandName() {
        return "$RevConnectToMe";
    }

    @Override
    public void parseCommand() {
        int startClientNick = getActualCommandName().length()+1;
        int endClientNick = getCommand().indexOf(" ", startClientNick);
        setClientNick(getCommand().substring(startClientNick, endClientNick));

        setTargetNick(getCommand().substring(endClientNick+1, getCommand().length()));
    }

    public String getClientNick() {
        return clientNick;
    }

    public void setClientNick(String clientNick) {
        this.clientNick = clientNick;
    }

    public String getTargetNick() {
        return targetNick;
    }

    public void setTargetNick(String targetNick) {
        this.targetNick = targetNick;
    }
}
